<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <h:head>
        <link rel="shortcut icon" href="images/favicon.ico"/>
        <title>JForum :: #{resourcesController.extractResource('TOPICS')}</title>
    </h:head>
    <h:body style="background-color: #111111">
      <div id="header">
		<ui:insert name="header" >
			<ui:include src="header.xhtml" />
		</ui:insert>
      </div>

      <center>
      
           <p:dataTable  var="thread"
                         value="#{forumThreadsBean.getThreads()}"
                         liveScroll="true"
                         style="width: 790px"
                         paginator="true" rows="10"
                         paginatorTemplate="{CurrentPageReport} {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}"
                         rowsPerPageTemplate="5,10,15">
                <f:facet name="header">

                    <c:if test="#{authorizationBean.user != null}">
                      <div align="left" style="float:left">
                        <h:form>
                          <p:commandLink action="/newthread.xhtml?faces-redirect=true" style="left: 20px">
                             <p:graphicImage url="/images/add.png" height="50"/>
                          </p:commandLink>
                        </h:form>
                      </div>
                    </c:if>
                    <h:outputText value="#{forumThreadsBean.currentBlock.name}" />
                </f:facet>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('TITLE')}" />
                    </f:facet>
                    <div style="width: 300px; word-wrap: break-word;">
                        <h:form>
                         <h:commandLink value="#{thread.name}"
                                        action="#{forumThreadsBean.showThread(thread)}"/>
                        </h:form>
                    </div>
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('AUTHOR')}" />
                    </f:facet>
                    <h:outputText value="#{thread.author}" />
                </p:column>

                <p:column>
                    <f:facet name="header">
                        <h:outputText value="#{resourcesController.extractResource('POSTS')}" />
                    </f:facet>
                    <h:outputText value="#{forumThreadsBean.getPostsNumber(thread)}" />
                </p:column>

                <c:if test="#{authorizationBean.user.gid le 2}">
                    <p:column style="width:250px">
                        <h:form>
                          <p:selectOneMenu value="#{forumThreadsBean.targetBlockName}"
                                           style="width:210px; height:30px; font-size:11pt">
                           <f:selectItems value="#{forumBlocksBean.blocks}"
                                          var="block"
                                          itemLabel="#{block.name}"
                                          itemValue="#{block.name}"/>
 
                          </p:selectOneMenu>
                          <br/>
                          
                          <p:commandLink value="#{resourcesController.extractResource('REPLACE')}"
                                           ajax="false"
                                           style="height:30px; font-size:11pt; font-weight: bolder; margin: 10px"
                                           action="#{forumThreadsBean.moveThread(thread)}"/>

                          <p:commandLink value="#{resourcesController.extractResource('REMOVE')}"
                                           ajax="false"
                                           style="height:30px; font-size:11pt; font-weight: bolder; margin: 10px"
                                           action="#{forumThreadsBean.removeThread(thread)}"/>
                         
                      </h:form>
                    </p:column>
                </c:if>
            </p:dataTable>

       
      </center>
      <ui:insert name="header" >
			<ui:include src="footer.xhtml" />
      </ui:insert>
    </h:body>
</html>

